import { uniqueId } from 'lodash'
import { Param, Person } from './types'
import toString, { toNumber, ConstObj, ConstVal, consoleObj, Student, parseDirection, arrowFunction } from './lib/index'

const getUUID = (param: Param): string => {
  return uniqueId(`${param.a}${param.b}`)
}
const p:Partial<Person> = {
  name: 'qwe'
}

const p1:Person = {
  name: 'qwe'
}

// console.log(getUUID({ a: 'stu_', b: 1 }))
// console.log(getUUID({ a: 'stu_', b: 2 }))
// console.log(getUUID({ a: 'stu_', b: 3 }))
ConstVal
ConstObj.name
console.log(toString(123))
console.log(toNumber('333'))

consoleObj({ name: '21123', age: 123123 })

const stu = new Student('stu1')
stu.getName()

parseDirection('right')

arrowFunction('123123')

// 函数重载
function overloadFunc(val: string): string;
function overloadFunc(val: number): number;
function overloadFunc(val: any): any {
  return val
}

overloadFunc(123)
overloadFunc('qwe')

// 利用函数签名实现箭头函数重载，用type或interface定义都可以
// type FuncType = {
//   (val: string): string
//   (val: number): number
// }
interface FuncType {
  (val: string): string
  (val: number): number
}

const overloadArrowFunc:FuncType = (val: any) => {
  return val
}

overloadArrowFunc(123)
overloadArrowFunc('qwe')

// testGlobalType这个类型并没有被导入，但是由于在当前项目某个d.ts文件中声明了，所以可以使用这个类型
let test: testGlobalType = {
  name: 'qwe'
}
let tes1: test1.testGlobalType = {
  name: 12
}
